<?php
require('config.php');

        $goods_id=$_REQUEST['goods_id'];
        $isGoodsContent='0';
        if(isset($_REQUEST['isGoodsContent'])) $isGoodsContent=$_REQUEST['isGoodsContent'];
		$sql="select * from `".$oto."_goods` where `goodsId`='".$goods_id."' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$goods_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($goods_info))
		{
			$goods_info[0]['goodsDesc']=htmlspecialchars_decode($goods_info[0]['goodsDesc']);
			$time_star=time();
			$time_end=$time_star-3600*24*30;
			$time_star1=date('Y-m-d H:i:s',$time_end);
			$time_end1=date('Y-m-d H:i:s',$time_star);
			$sql="select * from `".$oto."_orders`,`".$oto."_order_goods` where ".$oto."_orders.orderId=".$oto."_order_goods.orderId and ".$oto."_order_goods.goodsId='{$goods_id}' and createTime>='$time_star1' and createTime<='$time_end1' and orderStatus='4'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order_list[]=$row;//将取得的所有数据赋值给person_info数组
			}
			$sum=0;
			if(isset($order_list))
			{
				for($i=0;$i<count($order_list);$i++)
				{
					$sum+=$order_list[$i]['goodsNums'];
				}
			}
			$goods_info[0]['yue_xiaoliang']=$sum;
			$shopId=$goods_info[0]['shopId'];
			$sql="select * from `".$oto."_shops` where `shopId`='".$shopId."' LIMIT 1";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$shops[]=$row;//将取得的所有数据赋值给person_info数组
			}
			if(isset($shops))
			{
				$goods_info[0]['userTalkLink']=$shops[0]['userTalkLink'];
			}
			else $goods_info[0]['userTalkLink']="";
			$sql2="select * from `".$oto."_goods_attributes`,`".$oto."_attributes` where ".$oto."_goods_attributes.goodsId='$goods_id' and isPriceAttr=1 and ".$oto."_goods_attributes.attrId=".$oto."_attributes.attrId order by ".$oto."_attributes.attrId ASC";
			$result=$db->query($sql2);
			while($row=$result->fetch_assoc()){
				$shuxing_info=$row;//将取得的所有数据赋值给person_info数组
			}
			if(!isset($shuxing_info))
			{
				$goods_info[0]['is_shuxing']=0;
			}
			else
			{
				$goods_info[0]['is_shuxing']=1;
			}
			if($isGoodsContent!='0') $goods_info[0]['goodsDesc']="";
		}
		echo json_encode($goods_info);
?>